<?php
 $imgurl = $this->getSkinUrl('pms/images/jifenpc.png'); 
 $exchangeId = $this->getRequest()->getParam("exchange_id");
 $exchange = Mage::getModel("pms/exchange")->load($exchangeId);
 $data = $exchange->getFormData();
 if($data){
 	$result = json_decode($data,true);
 	$image = $result["image"];
 	$imageurl =Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
 }
 ?>
<div class="templets">
	<div class ="t-left">
		<div class="fieldset  ignore-validate" id="information_fieldset">
			<div class="hor-scroll">
				<table cellspacing="0" class="form-list">
				<tbody>
					<tr>
					    <td class="label"><label for="qty">活动背景</label></td>
					    <td class="value">
					    	<input type="text" name="form_data[activebackendcolor]" id="color" class="required-entry" value="<?php echo isset($result["activebackendcolor"])?$result["activebackendcolor"]:"#fff" ?>"  />
					    </td>    
					</tr>
					<tr><td><div id="picker"></div></td></tr>
				</tbody>
				</table>
			</div>
		</div>
		<div class="fieldset  ignore-validate" id="information_fieldset">
			<div class="hor-scroll">
				<table cellspacing="0" class="form-list">
				<tbody>
					<tr>
					    <td class="label"><label for="qty">banner图</label></td>
					    <td class="value">
					    	<input type="file" name="image[banner][]"/>
					    </td>
				        <?php if(!empty($image["banner"])): ?>
				        <td class="label"><button type="button" onclick='showimage("bannerimage")'><span>查看已上传图片</span></button></td>
				        <div id="bannerimage" style="display:none;"><img src="<?php echo $imageurl.$image["banner"]; ?>" alt=""></div>
				    	<?php endif; ?>
					</tr>
				</tbody>
				</table>
			</div>
		</div>

		<div class="fieldset  ignore-validate" id="information_fieldset">
			<div class="hor-scroll">
				<table cellspacing="0" class="form-list">
				<tbody>
					<tr>
					    <td class="label"><label for="qty">上传活动说明背景图片</label></td>
					    <td class="value">
					    	<input type="file" name="image[active][]"/>
					    </td>
				        <?php if(!empty($image["active"])): ?>
				        <td class="label"><button type="button" onclick='showimage("activeimage")'><span>查看已上传图片</span></button></td>
				        <div id="activeimage" style="display:none;"><img src="<?php echo $imageurl.$image["active"]; ?>" alt=""></div>
				    	<?php endif; ?>
					</tr>

				</tbody>
				</table>
			</div>
		</div>

		<div class="fieldset  ignore-validate" id="information_fieldset">
			<div class="hor-scroll">
				<table cellspacing="0" class="form-list">
				<tbody>
					<tr>
					    <td class="label"><label for="qty">上传热门兑换图片</label></td>
					    <td class="value">
					    	<input type="file" name="image[hot][]"/>
					    </td>
				        <?php if(!empty($image["hot"])): ?>
				        <td class="label"><button type="button" onclick='showimage("hotimage")'><span>查看已上传图片</span></button></td>
				        <div id="hotimage" style="display:none;"><img src="<?php echo $imageurl.$image["hot"]; ?>" alt=""></div>
				    	<?php endif; ?>
					</tr>
				</tbody>
				</table>
			</div>
		</div>


		<div class="fieldset  ignore-validate" id="information_fieldset">
			<div class="hor-scroll">
				<table cellspacing="0" class="form-list">
				<tbody>
					<tr>
					    <td class="label"><label for="qty">热门兑换商品背景</label></td>
					    <td class="value">
					    	<input type="text" name="form_data[hotbackendcolor]" id="colorh" class="required-entry"  value="<?php echo isset($result["hotbackendcolor"])?$result["hotbackendcolor"]:"#da292e" ?>" />
					    </td>
					</tr>
					<tr><td><div id="pickerh"></div></td></tr>
				</tbody>
				</table>
			</div>
		</div>

		<div class="fieldset  ignore-validate" id="information_fieldset">
			<div class="hor-scroll">
				<table cellspacing="0" class="form-list">
				<tbody>
					<tr>

					    <td class="label"><label for="qty">上传超值兑换图片</label></td>
					    <td class="value">
					    	<input type="file" name="image[sell][]"/>
					    </td>
				        <?php if(!empty($image["sell"])): ?>
				        <td class="label"><button type="button" onclick='showimage("sellimage")'><span>查看已上传图片</span></button></td>
				        <div id="sellimage" style="display:none;"><img src="<?php echo $imageurl.$image["sell"]; ?>" alt=""></div>
				    	<?php endif; ?>
					</tr>
					
				</tbody>
				</table>
			</div>
		</div>

		<div class="fieldset  ignore-validate" id="information_fieldset">
			<div class="hor-scroll">
				<table cellspacing="0" class="form-list">
				<tbody>
					<tr>
					    <td class="label"><label for="qty">超值兑换背景</label></td>
					    <td class="value">
					    	<input type="text" name="form_data[sellbackendcolor]" id="colors" class="required-entry"   value="<?php echo isset($result["sellbackendcolor"])?$result["sellbackendcolor"]:"#00dcc6" ?>" />
					    </td>
					</tr>
					<tr><td class="right"><div id="pickers"></div></td></tr>
				</tbody>
				</table>
			</div>
		</div>

		<div class="fieldset  ignore-validate" id="information_fieldset">
			<div class="hor-scroll">
				<table cellspacing="0" class="form-list">
				<tbody>
					<tr>
					    <td class="label"><label for="qty">更多商品跳转地址</label></td>
					    <td class="value">
					    	<input type="text" name="form_data[productsUrl]" id="colors" class="required-entry"   value="<?php echo isset($result["productsUrl"])?$result["productsUrl"]:"" ?>" />
					    </td>
					</tr>
				</tbody>
				</table>
			</div>
		</div>




	</div>
	<div class ="t-right">
		<img src = "<?php echo $imgurl; ?>"/>
	</div>
</div>
<script type="text/javascript">
		var  $j = jQuery.noConflict(); 
			$j(document).ready(function(){
			$j('#picker').farbtastic('#color'); 
			$j('#pickers').farbtastic('#colors'); 
			$j('#pickerh').farbtastic('#colorh'); 
			$j('#end_at').datetimepicker({
			      lang:"ch",
			      timepicker:false,
			});
		});
		$j(".resets").click(function(){
			var color = $j(this).attr("color");
			$j(this).prev().val(color);
		});
		function showimage(image){
			var image = $j("#"+image);
			var imagetype = image.find("img");
			var w = imagetype.offsetWidth;
	        var h = imagetype.offsetHeight;
			layer.open({
			  type: 1,
			  title: "查看已上传图片",
			  closeBtn: 1,
			  shade: [0.6, '#000'],
			  area: [w, h],
			  skin: 'layui-layer-nobg',
			  shadeClose: true,
			  content:image
			});
		}
</script>